import 'package:aichat_flutter_wallet/module/module_user_info/model/user_info_model.dart';
import 'package:lib_database/lib_database.dart';
import 'package:lib_network/http_config.dart';
import 'package:lib_network/http_manager.dart';

import '../../../module_common/network/http_api.dart';

class UserInfoApi{
  // 获取有效积分消息数量
  static Future<FollowListResponse?> getFollowList({ required FansTabsType scene,String? keyword = null,int page=1,int size=15 ,userId = '' }) async {
    try {
      var resp = await HttpManager().post(API.getFollowList+'?userId=${userId}&page=${page.toString()}&size=${size.toString()}&scene=${(scene.index+1).toString()}'+ (keyword==null?'':'&keyword=${keyword}'),
          {});
      print('getFollowList ${scene} : ${resp!.data}');
      if (resp.code == HttpConfig().successCode) {
        // 0  或者 1
        return FollowListResponse.fromJson(resp!.data);
      }
      throw Exception('getFollowList 获取网络异常');
    } catch (e) {
      print('getFollowList 失败: $e');
      throw Exception('getFollowList 获取网络异常');
    }
  }

  // 获取有效积分消息数量
  static Future<int?> postFollow(String userId) async {
    try {
      var resp = await HttpManager().post(API.postFollow, {
        'user_id': userId
      });
      if (resp!.code == HttpConfig().successCode) {
        // 0  或者 1
        return int.parse(resp!.data['status'].toString());
      }else if (resp!.code == 5) {
        // 0  或者 1
        return -1;
      }else if (resp!.code == 7) {
        // 0  或者 1
        return -2;
      }
      throw Exception('getFollowList 获取网络异常');
    } catch (e) {
      print('getTaskIsFinishStatus 失败: $e');
      throw Exception('getFollowList 获取网络异常');
    }
  }

}